package com.dididoctor.doctor.Activity.Order.DiagnosisSuggest;

import android.content.Context;
import android.view.View;

import com.dididoctor.doctor.Bean.SuggestBean;
import com.dididoctor.doctor.MV.adapter.CommonAdapter;
import com.dididoctor.doctor.MV.adapter.ViewHolder;
import com.dididoctor.doctor.R;

import java.util.List;

/**
 * @version 2.0
 * @类描述：
 * @项目名称：ddgh
 * @类名称： suggestAdapter
 * @包名称： com.dididoctor.doctor.Activity.Order
 * @创建人： 李营
 * @创建时间：2016/4/25 18:43
 * @修改人：
 * @修改时间：2016/4/25 18:43
 * @修改备注： new parent class(用一句话描述修改了什么)
 */
public class SuggestAdapter extends CommonAdapter<SuggestBean> {
    private Context context;

    public SuggestAdapter(Context context, List<SuggestBean> datas) {
        super(context, datas, R.layout.item_suggest);
        this.context = context;
    }

    @Override
    public void convert(final int position, ViewHolder helper, SuggestBean item) {

        String content = item.getContent();
        if (content != null && !"".equals(content)) {
            helper.setText(R.id.tv_content, content);
        } else {
            helper.setText(R.id.tv_content, "很抱歉，没有成功获取到建议内容");
        }

        String tag = item.getTag();
        if(tag!=null&&!"".equals(tag)){
            if(tag.equals("0")){
                helper.getView(R.id.iv_tag).setBackgroundResource(R.drawable.shape_suggest_press);
            }else{
                helper.getView(R.id.iv_tag).setBackgroundResource(R.drawable.shape_suggest_normal);
            }
        }

        helper.getConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ((SuggestListView)(context)).dataChange(position);
            }
        });
    }
}
